Skip to content

Add server limits with UTF-16 truncation and bounded IDs - #49

Open
DzmitryHumianiuk wants to merge 2 commits into
masterfrom
feat/truncation-limits
Open

DzmitryHumianiuk wants to merge 2 commits into
masterfrom
feat/truncation-limits

Conversation

@DzmitryHumianiuk

@DzmitryHumianiuk DzmitryHumianiuk commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #27 (slice L2). No dependencies; merges cleanly with L1, L4 and L5.

Pure functions that shorten values to what the server accepts, counted the way the server counts (UTF-16 code units) and never splitting a character. The starting point is pkg/ginkgo/rpagent/limits.go of PR #15 (at 07ad5c4). Nothing calls them yet: the CLI and the Ginkgo agent adopt them in their own PRs.

Changes

  • pkg/gorp/limits.go (new):
    • constants MaxLaunchNameLength 256, MaxItemNameLength 1024, MaxDescriptionLength 2048, MaxUniqueIDLength 1024, MaxTestCaseIDLength 1024, MaxAttributes 256, MaxAttributeLength 128;
    • Truncate(s, limit): cuts to limit UTF-16 units and ends with ..., like the Java client;
    • BoundedID(id, limit): prefix + ~ + 16 hex digits of SHA-256 of the whole ID, so long IDs stay unique and stable;
    • TruncateAttributes(attrs): at most 256 attributes, keys and values of at most 128; returns a new slice.
  • pkg/gorp/limits_test.go (new).
  • README ("Server limits"), AGENTS.md.

Differences from the #15 original:

  • BoundedID counts UTF-16 units. The original compared bytes, so an ID of 400 three-byte characters (400 units, 1200 bytes) was shortened although the server accepts it.
  • Truncate takes the limit as an argument instead of being bound to item names.
  • The width of a character is computed directly instead of allocating through utf16.Encode per character.

Limits and their source

service-api develop at 017642e9, paths under src/main/java/com/epam/reportportal/base/; migrations at 956ef1ad; client-java 5.4.16-SNAPSHOT at 1d8ecdae.

Limit Value Source Over the limit
Launch name 256 reporting/StartLaunchRQ.java:43 (@NotBlankWithSize(max = MAX_NAME_LENGTH)), reporting/ValidationConstraints.java:33 400
Item name 1024 reporting/StartTestItemRQ.java:92, reporting/ValidationConstraints.java:29 400
Description (launch and item) 2048 ws/converter/builders/LaunchBuilder.java:43,69-74, TestItemBuilder.java:50,108-113 (StringUtils.substring(it.trim(), 0, 2048)) cut silently
uniqueId 1024 reporting/StartTestItemRQ.java:58 (@Size(max = MAX_TEST_ITEM_UNIQUE_ID_LENGTH)), ValidationConstraints.java:30 400
testCaseId 1024 ws/converter/builders/TestCaseIdEntry.java:33,45-51; column VARCHAR(1024) in migrations 14_test_case_id_size_increase.up.sql:2 the server keeps the first 1011 characters and appends [hashCode of the rest]
Number of attributes 256 reporting/StartRQ.java:53, reporting/FinishExecutionRQ.java:66 (@Size(max = MAX_PARAMETERS_LENGTH)), ValidationConstraints.java:36 400
Attribute key / value 128 cut silently at 512 by reporting: ws/converter/converters/AttributeConverter.java:32-43 (MAX_ATTRIBUTE_LENGTH = 512, substring). 128 is the default of the Java client, listeners/ListenerParameters.java:71, and stays below the server cut nothing (cut)

The unit is UTF-16: the name validator compares value.length() (infrastructure/annotations/NotBlankWithSizeValidator.java:58), @Size on a String does the same, and the description is cut with substring.

Points that differ from the plan in #27 and from the Java client:

  • Item descriptions are cut at 2048, not 65536. The Java client still truncates item descriptions to 65536 (service/LaunchImpl.java:89,389-399), the server at this commit keeps 2048. MaxDescriptionLength follows the server.
  • The finish-launch description shares the 2048 budget with the start description: core/launch/impl/FinishLaunchHandlerImpl.java:110,131-138 joins them with a space before addDescription cuts.
  • testCaseId is not rejected and not lost. The server shortens it itself. BoundedID is still useful there to decide what is stored (the server's hash of the tail is 32-bit), but it is uniqueId where it is needed: a long one fails the request.
  • MAX_ATTRIBUTE_LENGTH = 512 exists twice: in infrastructure/model/ValidationConstraints.java:51 (project and filter handlers) and in AttributeConverter.java:32, which reporting uses to cut keys and values. The first version of this description said reporting has no limit; corrected after the live check (see comment).

Behaviour change

None. New exported API only.

Verification

On feat/truncation-limits (36a222d):

  • go build ./... && go vet ./...: ok
  • go test -race ./...: ok
  • go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.15.0 run ./...: 0 issues
  • No live check, see "Not verified".

Tests cover: lengths checked against an independent utf16.Encode count; a surrogate pair at the cut is not split (emoji, mixed text, limits too small for the mark); BMP characters that are 3 bytes in UTF-8 count as one; invalid UTF-8; the result at every server limit is within the limit and at most one unit short of it; BoundedID is stable, keeps IDs with a common prefix different, and matches a value computed with shasum -a 256; tiny limits; TruncateAttributes keeps the input untouched and the order.

Investigation log

  1. git fetch origin pull/15/head:pr15-wave, git show 07ad5c4:pkg/ginkgo/rpagent/limits.go; the local branch is deleted again.
  2. grep -rn "MAX_\|MIN_" --include=ValidationConstraints.java src in service-api: two copies of the constants; the reporting DTOs import base.reporting.ValidationConstraints.
  3. grep -n "@Size\|@NotBlank\|MAX_" reporting/{StartRQ,StartLaunchRQ,StartTestItemRQ,AttributeResource,FinishExecutionRQ,ParameterResource}.java gave the annotations in the table. description, codeRef, testCaseId and parameters carry no size annotation.
  4. LaunchBuilder.java and TestItemBuilder.java showed the silent cut of descriptions; grep -rn addDescription core/ showed that start, finish, stop and rerun all go through the same builders.
  5. TestCaseIdEntry.java showed the server-side cropping of testCaseId. My first reading (from the column size alone) was that a long ID fails when stored; that was wrong and is corrected.
  6. Migrations: 1_initialize_schema.up.sql:386,420 (launch.name VARCHAR(256), test_item.name VARCHAR(1024)), 4_size_limitations.up.sql:8-9 (unique_id VARCHAR(1024), code_ref VARCHAR), 14_test_case_id_size_increase.up.sql:2, 1_initialize_schema.up.sql:503-504 (item_attribute.key/value VARCHAR, no length). PostgreSQL counts characters, Java counts UTF-16 units, so a value within the Java limit always fits the column.
  7. 92_start_time_idx.up.sql:2 creates a btree index on item_attribute (key, value). A btree entry can't exceed about a third of a page, so very long attributes (kilobytes) may fail to insert. 128 is far below that.

Not verified

  • Nothing here was checked against a live server. Checked later on a local ReportPortal 6.0.0, see the PR comment.
  • Limits of 5.x servers. The DTOs of 5.x live in the separate commons-model artifact, which I did not read. The PR Add Ginkgo v2 agent and ginkgo-rp wrapper (pkg/ginkgo) #15 comment reports 1024 for item names and a "silently cut" testCaseId on a live 5.x, which agrees with the table.
  • Whether older servers kept item descriptions longer than 2048 (the Java client's 65536 suggests so).
  • The btree size limit on attribute values (item 7) is from PostgreSQL behaviour in general, not tested.

🤖 Generated with Claude Code

Truncate shortens names, descriptions and attributes to the server's
limits, counted in UTF-16 code units like the server does and never
splitting a character. BoundedID shortens testCaseId/uniqueId to a
prefix plus a hash of the whole ID, so long IDs stay unique and stable.
The limits are constants taken from the service-api validation rules.

Part of #27

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Checked on ReportPortal 6.0.0: a 3000-character key and value are stored
as 512/512 (AttributeConverter.MAX_ATTRIBUTE_LENGTH in service-api). The
128 default stays below that, so only the comment and README change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DzmitryHumianiuk

Copy link
Copy Markdown
Member Author

Local ReportPortal 6.0.0 check (same build as demo, rc/6.0.0-038258bf):

  • Every limit in the table holds live: launch name 256 and item name 1024, counted in UTF-16 units (emoji names at 256/258 → 201/400); descriptions cut silently at 2048; uniqueId 1025 → 400; 257 attributes → 400; testCaseId 1025 stored as 1022 characters. v2 validates these synchronously too (400 before queueing).
  • Output of Truncate, BoundedID and TruncateAttributes is accepted: a 255-unit name ending in 😀..., a 1024-unit BoundedID as uniqueId (raw 3000 → 400), 256 attributes with 128-unit values.
  • One correction to the description: attribute keys and values are cut by reporting, silently at 512 (ws/converter/converters/AttributeConverter.java:32-63). A 3000-character key and value were stored as 512/512. MaxAttributeLength = 128 stays below that, so the behaviour doesn't change. d8054dc fixes the doc comment of MaxAttributeLength and the README, and the description is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants